var express = require('express');
var router = express.Router();
var spawn = require('child_process').spawn;

/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.get('/startexe', function(req, res, next) {
  console.log("I will start exe!");
  exe = spawn('/mnt/share/software/MeteoInfo/meteoinfo.sh');
  // 捕获标准输出并将其打印到控制台 
  free.stdout.on('data', function (data) { 
    console.log('standard output:\n' + data); 
  });
  // 捕获标准错误输出并将其打印到控制台 
  free.stderr.on('data', function (data) { 
    console.log('standard error output:\n' + data); 
  });
  // 注册子进程关闭事件 
  free.on('exit', function (code, signal) { 
    console.log('child process eixt ,exit:' + code); 
  });
       
});

module.exports = router;
